﻿using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ms.Util;

namespace ms
{
    public class GraphicsGL : Singleton<GraphicsGL>
    {
        public SpriteBatch Batch => GameUtil.Instance.Batch;
        public SpriteFont Font_Arial { get; set; }
        public GraphicsGL()
        {

        }

        public void drawrectangle(int x, int y, int width, int height, float red, float green, float blue, float alpha)
        {
            Batch.Draw(Batch.BlankTexture(), new Rectangle(x, y, width, height), new Microsoft.Xna.Framework.Color(red, green, blue, alpha));
        }
        public void drawrectangle(int x, int y, int width, int height, Microsoft.Xna.Framework.Color color)
        {
            Batch.Draw(Batch.BlankTexture(), new Rectangle(x, y, width, height), color);
        }
        public void drawrectangle(Rectangle rectangle, Microsoft.Xna.Framework.Color color)
        {
            Batch.Draw(Batch.BlankTexture(), rectangle, color);
        }

        public void DrawWireRectangle(int x, int y, int width, int height, Microsoft.Xna.Framework.Color color, int lineWidth = 4)
        {
            var rectTop = new Rectangle(x, y, width, lineWidth);
            var rectBot = new Rectangle(x, y + height - lineWidth, width, lineWidth);
            var rectLeft = new Rectangle(x, y, lineWidth, height);
            var rectRight = new Rectangle(x + width - lineWidth, y, lineWidth, height);

            Batch.Draw(Batch.BlankTexture(), rectTop, color);
            Batch.Draw(Batch.BlankTexture(), rectBot, color);
            Batch.Draw(Batch.BlankTexture(), rectLeft, color);
            Batch.Draw(Batch.BlankTexture(), rectRight, color);
        }

        public void DrawWireRectangle(FairyGUI.Drawing.RectangleF rect, Microsoft.Xna.Framework.Color color, int lineWidth = 4)
        {
            DrawWireRectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height, color, lineWidth);
        }
    }
}